package com.annhoa.ribbon;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


//@EnableFeignClients：Feign 是一个声明web服务客户端，使用Feign 创建一个接口并对它进行注解，
// 它具有可插拔的注解支持包括Feign注解与JAX-RS注解SpringCloud对Feign进行了封装，使其支持SpringMVC
// 标准注解和HttpMessageConverters。Feign可以    与    Eureka和Ribbon组合使用以支持负载均衡。
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrix          //添加熔断机制
public class RibbonApplication {

    public static void main(String[] args) {
        SpringApplication.run(RibbonApplication.class, args);
    }

    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
